package Ex01;
import java.util.Scanner;

public class Stage01 {
    public static void main(String[] args) {

        System.out.println("ZlT01\n");
        System.out.println("**************************************");
        System.out.println("请选择购买的商品编号：");
        System.out.println("**************************************");
        System.out.println("1.T袖\t2.网球\t");
        System.out.println("**************************************");

        //变量
        String customer = "";
        String goodName = "";//商品名称
        int goodsNo = 1;//编号
        double goodsPrice = 0;//商品价格
        int amount = 0;//数量
        double discount = 0.0;//折扣
        double total = 0.0;//未打折时 商品的总价
        double finalpay = 0.0;//打折后 实际消费
        String answer = "y";
        Scanner input = new Scanner(System.in);
        //循环
        while(answer.equals("y"))
        {
            System.out.print("请输入商品编号：");
            goodsNo = input.nextInt();
            System.out.print("请输入商品的数量：");
            amount = input.nextInt();
            switch(goodsNo)
            {
                case 1:
                    goodName = "T袖";
                    goodsPrice = 420.78;
                    discount = 9.8;
                    break;
                case 2:
                    goodName = "网球";
                    goodsPrice = 45;
                    discount = 1;
                    break;
                default:
                    System.out.println("您输入的商品编号有误，请重新输入(1-2)");
            }
            System.out.print("购物者：");
            customer = input.next();
            System.out.println(goodName+"\t￥" + goodsPrice+ "\t数量" + amount +"\t折扣" + discount + "\t合计" + (goodsPrice*amount));
            System.out.println("是否继续？(y/n)");
            answer = input.next();

        }

        total = goodsPrice*amount;
        finalpay = total*discount;
        System.out.println(customer + "\t花费\t" +finalpay);

    }
}
